package com.augurit.gzcgwsp.ywcmn.convert;

import java.util.ArrayList;
import java.util.List;

import org.dozer.DozerBeanMapper;
import com.augurit.gzcgwsp.ywcmn.entity.YwComYsgs;
import com.augurit.gzcgwsp.ywcmn.web.form.YwComYsgsForm;

public class YwComYsgsConvertor {
	public static YwComYsgsForm convertVoToForm(YwComYsgs entity) {
		if (entity == null) return null;
		
		return new DozerBeanMapper().map(entity, YwComYsgsForm.class);
	}
	
	public static void convertFormToVo(YwComYsgsForm form, YwComYsgs entity) {
		
		if(form.getId() != null)
			entity.setId(form.getId());
		if(form.getTemplateCode() != null && form.getTemplateCode().trim().length() > 0)
			entity.setTemplateCode(form.getTemplateCode());
		if(form.getSqrq() != null)
			entity.setSqrq(form.getSqrq());
		if(form.getUpdateDate() != null)
			entity.setUpdateDate(form.getUpdateDate());
		if(form.getYsgs() != null)
			entity.setYsgs(form.getYsgs());
		if(form.getYsgsLxr() != null)
			entity.setYsgsLxr(form.getYsgsLxr());
		if(form.getYsgsLxrLxdh() != null)
			entity.setYsgsLxrLxdh(form.getYsgsLxrLxdh());
		
		
	}
	
	public static List<YwComYsgsForm> convertVoListToFormList(List<YwComYsgs> ywComYsgsList) {
		if(ywComYsgsList != null && ywComYsgsList.size() > 0) {
			List<YwComYsgsForm> ywComYsgsFormList = new ArrayList<YwComYsgsForm>();
			for(int i=0; i<ywComYsgsList.size(); i++) {
				ywComYsgsFormList.add(convertVoToForm(ywComYsgsList.get(i)));
			}
			return ywComYsgsFormList;
		}
		return null;
	}
	
	public static List<YwComYsgs> convertFormListToVoList(List<YwComYsgsForm> ywComYsgsFormList) {
		if(ywComYsgsFormList != null && ywComYsgsFormList.size() > 0) {
			List<YwComYsgs> ywComYsgsList = new ArrayList<YwComYsgs>();
			for(int i=0; i<ywComYsgsFormList.size(); i++) {
				YwComYsgs ywComYsgs = new YwComYsgs();
				convertFormToVo(ywComYsgsFormList.get(i), ywComYsgs);
				ywComYsgsList.add(ywComYsgs);
			}
			return ywComYsgsList;
		}
		return null;
	}
}